import request from "@/utils/request";
import { AxiosPromise } from "axios";
import {
  ReceiptForm,
  ReceiptUser,
  WorkPaperForm,
  WorkPaperPage,
  WorkPaperQuery,
} from "./types";

/**
 * 获取分页列表
 *
 * @param queryParams
 */
export function getWorkPaperPage(
  queryParams: WorkPaperQuery
): AxiosPromise<PageResult<WorkPaperPage[]>> {
  return request({
    url: "/admin/workPaper/index",
    method: "get",
    params: queryParams,
  });
}

export function getBoardPage(
  queryParams: WorkPaperQuery
): AxiosPromise<PageResult<WorkPaperPage[]>> {
  return request({
    url: "/admin/workPaper/board",
    method: "get",
    params: queryParams,
  });
}

/**
 * 获取表单详情
 *
 * @param ids
 */
export function getWorkPaperForm(ids: string): AxiosPromise<WorkPaperForm> {
  return request({
    url: "/admin/workPaper/edit",
    method: "get",
    params: {
      ids: ids,
    },
  });
}

export function getReceiptUser(): AxiosPromise<ReceiptUser> {
  return request({
    url: "/admin/workPaper/receiptUser",
    method: "get",
  });
}

/**
 * 添加
 *
 * @param data
 */
export function addWorkPaper(data: any) {
  return request({
    url: "/admin/workPaper/add",
    method: "post",
    data: data,
  });
}

/**
 * 修改
 *
 * @param id
 * @param data
 */
export function updateWorkPaper(data: WorkPaperForm) {
  return request({
    url: "/admin/workPaper/edit",
    method: "put",
    data: data,
  });
}

export function receiptWorkPaper(data: ReceiptForm) {
  return request({
    url: "/admin/workPaper/receipt",
    method: "put",
    data: data,
  });
}

/**
 * 删除
 *
 * @param data
 */
export function deleteWorkPaper(data: any) {
  return request({
    url: "/admin/notice/del",
    method: "delete",
    data,
  });
}
